<template>
	<view class="apply">
		<public-module></public-module>
		<view class="u-page">
			<button class="but" @click="scanCode()" >扫码核销</button>
		</view>
		<tabBar selectedIndex=1 plugins=2></tabBar>
		<u-modal :show="show" :title="title" :content='content' @confirm="show =false"></u-modal>
	</view>
</template>

<script>
	import base from '@/config/baseUrl';
	import tabBar from "@/components/tabbar/tabbar.vue"
	import { exchange } from '@/config/api.js';
	export default {
		data() {
			return {
				show:false,
				title:'核销信息',
				content:''
			};
		},
		components:{
			tabBar
		},
		onLoad() {
			this.scanCode()
			// this.exchangeApi('kfjgkjfkgjdkfjgk')
		},
		methods: {
			scanCode()
			{
				let _this = this;
				uni.scanCode({
					scanType: ["qrCode"],
					success: (res) => {
						if (res.result) {
							// uni.navigateTo({
							// 	url: '/staff/orderInfo/orderInfo?order_no='+res.result
							// });
							_this.exchangeApi(res.result)
						} else {
							return false;
						}
					},
					fail: (res) => {
					}
				})
			},
			
			exchangeApi(order_no)
			{
				let _this =this;
				let httpData={
					order_no:order_no
				};
				exchange(httpData).then((res) => {
			
					if(res.code == 0)
					{
						_this.title = '核销成功'
						_this.content = res.content,
						_this.show = true
					}else{
						_this.title = '核销失败'
						_this.content = res.message,
						_this.show = true
					}
				}).catch((err) =>{
					
				})
			}
			
		}
		
	}
</script>

<style lang="scss">
	page{
		background-color: #fff;
	}
	.u-page{
		.but{
			box-sizing: border-box;
			 border: 1px solid #33B37E;  
			 margin: 500rpx 150rpx;
			 color: #33B37E;
			 box-shadow:
			    0 1px 3px rgba(0, 0, 0, 0.1), /* 上边框阴影 */  
			    1px 0 3px rgba(0, 0, 0, 0.1), /* 右边框阴影 */  
			    0 -1px 3px rgba(0, 0, 0, 0.1), /* 下边框阴影 */  
			    -1px 0 3px rgba(0, 0, 0, 0.1); /* 左边框阴影 */
		}
	}

</style>
